﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System.Collections.Generic;
using System.ComponentModel;
using Sebarf.Core.Interfaces;
using Sebastof.Services.Interfaces;

#endregion

namespace InterLinq.Views {
	/// <summary>
	/// Description of the class
	/// </summary>
	public class TypedView : ISebastofApplicationObject {

		#region Public Properties

		public GenericView UsedGenericView {
			get { return m_dataContainer; }
			private set { m_dataContainer = value; }
		}

		#endregion

		#region Public Methods

		public TypedView(GenericView dataContainer) {
			m_dataContainer = dataContainer;
		}

		protected internal TypedView() {
		}

		internal View SetUsedGenericView<View>(GenericView view) where View : TypedView {
			m_dataContainer = view;
			return this as View;
		}

		#endregion

		#region Private Fields

		private GenericView m_dataContainer;

		#endregion

		#region ISebastofApplicationObject Members

		public KeyValuePair<string, object>[] GetValues() {
			return m_dataContainer.GetValues();
		}

		public IServiceLocatorService AttachedServiceLocatorService {
			get { return m_dataContainer.AttachedServiceLocatorService; }
		}

		public IDataHandlingStrategy UsedDataHandlingStrategy {
			get { return m_dataContainer.UsedDataHandlingStrategy; }
		}

		public object GetValue(string key) {
			return m_dataContainer.GetValue(key);
		}

		public T GetValue<T>(string key) {
			return m_dataContainer.GetValue<T>(key);
		}

		public void SetValue(string key, object value) {
			m_dataContainer.SetValue(key, value);
		}

		public void SignalIsCommited() {
			m_dataContainer.SignalIsCommited();
		}

		public void RegisterSetValueObserver(IAppliedChangesOnObjectsCollectorService callback) {
			m_dataContainer.RegisterSetValueObserver(callback);
		}

		public void DeRegisterSetValueObserver(IAppliedChangesOnObjectsCollectorService callback) {
			m_dataContainer.DeRegisterSetValueObserver(callback);
		}

		public event PropertyChangedEventHandler PropertyChanged;

		public string Id {
			get { return m_dataContainer.Id; }
			set { m_dataContainer.Id = value; }
		}

		public object GetVersion() {
			return 0;
		}

		public bool CurrentVersionMatchs(object previousVersion) {
			return true;
		}

		public object IncreaseVersion() {
			return 0;
		}

		public void SetVersion(object o) {
		}

		#endregion
	}
}